<template>
	<view class="order_main">
		<NavTabbar activeTab="order"></NavTabbar>

		<view class="navbar">
			<view class="fixed">
				<!-- 状态栏 时间 电量 信号 -->
				<view :style="{height: navbarStatusHeight + 'px'}"></view>
				<!-- #ifdef H5 || APP-PLUS || MP-ALIPAY -->
				<view class="navbar-content">
					<!-- <uni-icons type="back" @click="back" color="#fff" size="26" class="back_btn"></uni-icons> -->
					<view class="navBar">
						<view>工单</view>
					</view>
				</view>
				<!-- #endif -->

				<!-- #ifndef H5 || APP-PLUS || MP-ALIPAY -->
				<!-- 胶囊按钮左侧位置 -->
				<view
					class="navbar-content"
					:style="{width: '100%', height: navBarHeight + 'px'}"
				>
					<!-- <uni-icons type="back" @click="back" color="#fff" size="26" class="back_btn"></uni-icons> -->
					<view class="navBar">
						<view>工单</view>
					</view>
				</view>
				<!-- #endif -->
			</view>
			<!-- 设置占位 将微信小程序的状态栏高度预留出来 -->
			<!-- <view :style="{height:navbarStatusHeight+navBarHeight+'px' }"></view> -->
		</view>
		<view class="body-view">
			<view class="search_box">
				<uni-easyinput
					class="search"
					type="text"
					placeholderStyle="font-size:28rpx;"
					@confirm="search"
					:inputBorder="false"
					@clear="clear"
					prefixIcon="search"
					@input="input"
					v-model="selectValue"
					placeholder="请输入单号/名称搜索"
				></uni-easyinput>
				<view class="search_btn" @click="search">搜索</view>
			</view>
			<!-- 使用scroll-view实现tabs滑动切换 -->
			<scroll-view
				class="top-menu-view"
				scroll-x="true"
				:scroll-into-view="tabCurrent"
				:scroll-with-animation="true"
			>
				<view
					class="menu-topic-view"
					v-for="(item, index) in tabs"
					:id="'tabNum' + (index + 1)"
					:key="index"
					@click="swichMenu(index)"
				>
					<view :class="currentTab == index ? 'menu-topic-act' : ''">
						<text class="menu-topic-text">{{ item.name }}</text>
						<view
							class="red_num"
							v-if="OrderStatusQty && setOrderNum(item.status) != 0"
						>
							{{ setOrderNum(item.status) }}
						</view>
						<view class="menu-topic-bottom">
							<view class="menu-topic-bottom-color"></view>
						</view>
					</view>
				</view>
			</scroll-view>

			<!-- 使用scroll-view实现tabs滑动切换 子状态-->
			<scroll-view
				class="top-menu-view top-menu-view-child"
				scroll-x="true"
				:scroll-into-view="tabCurrentChild"
				v-if="currentTab ? [4, 6].includes(tabs[currentTab].status) : false"
				:scroll-with-animation="true"
			>
				<view
					class="menu-topic-view"
					v-for="(item, index) in childStatusList"
					:id="'tabNumChild' + (index + 1)"
					:key="index"
					@click="swichMenuChild(index)"
				>
					<view :class="currentTabChild == index ? 'menu-topic-act' : ''">
						<text class="menu-topic-text">{{ item.name }}</text>
						<view
							class="num_child"
							v-if="
								OrderStatusQty &&
								setOrderNum(item.status, tabs[currentTab].status) != 0
							"
						>
							{{ setOrderNum(item.status, tabs[currentTab].status) }}
						</view>
						<view class="menu-topic-bottom">
							<view class="menu-topic-bottom-color"></view>
						</view>
					</view>
				</view>
			</scroll-view>

			<!-- 内容 -->
			<swiper
				class="swiper-box-list"
				:current="currentTab"
				:disable-touch="true"
			>
				<swiper-item
					class="swiper-topic-list"
					v-for="(item, index) in PageTotalData"
					:key="index"
				>
					<view class="scroll_content" v-if="currentTab == index">
						<scroll-view
							class="scroll-view_list"
							:refresher-triggered="triggered"
							refresher-background="transparent"
							@refresherpulling="refresherpulling"
							refresher-enabled="true"
							scroll-y="true"
							@scrolltolower="scrolltolower"
							@refresherrefresh="onRefresh"
						>
							<view class="pag_bottom">
								<view
									class="list-item"
									v-for="(itemObj, indexObj) in item.dataList"
									:key="indexObj"
									@click="goDetail(itemObj.id)"
								>
									<view class="list-item_contenVo">
										<view class="list-item_contenVo_left">
											<!-- <view class="list-item_contenVo_left_tip">
												工单编码：
											</view> -->
											<view
												class="list-item_contenVo_left_wNo"
												style="font-weight: bold"
											>
												{{ itemObj.workNo }}
												<image
													@click.native.stop="copyText(itemObj.workNo)"
													style="width: 30rpx; height: 30rpx"
													src="/static/copy.svg"
													mode="aspectFit"
												></image>
											</view>
											<view class="list-item_contenVo_left_mo">
												{{ itemObj.module }}
											</view>
										</view>
										<view
											v-if="itemObj.isPause === 1"
											class="list-item_contenVo_right_tag"
											:style="{
												backgroundColor: '#e69103',
												'--item-color': '#e69103',
											}"
										>
											已挂起
										</view>
										<view
											v-else
											class="list-item_contenVo_right_tag"
											:style="{
												backgroundColor: status.filter(
													(o) => itemObj.status == o.status,
												)[0].color,
												'--item-color': status.filter(
													(o) => itemObj.status == o.status,
												)[0].color,
											}"
										>
											{{
												status.filter((o) => itemObj.status == o.status)[0].name
											}}
										</view>
									</view>
									<view class="list-item_contenVo">
										<view class="list-item_contenVo_left">
											<view class="list-item_contenVo_left_tip">
												客户名称：
											</view>
											<view class="list-item_contenVo_left_wNo">
												{{ itemObj.userName }}
											</view>
										</view>
										<view
											class="red_tag"
											v-if="
												!store.state.isManager &&
												itemObj.hasEngineerApplyOrderWaitCheck &&
												itemObj.hasEngineerApplyOrderWaitCheckType == 1 &&
												itemObj.status === 2
											"
										>
											已申请转单
										</view>
										<view
											class="red_tag"
											v-if="
												itemObj.hasNetworkApplyOrderWaitCheck &&
												(store.state.isManager
													? itemObj.status === 4
													: itemObj.status === 2)
											"
										>
											{{
												itemObj.hasNetworkApplyOrderWaitCheckType == 1
													? '已申请取消'
													: '已申请改派'
											}}
										</view>
										<view
											class="red_tag"
											v-if="
												store.state.isManager &&
												itemObj.waitCheckOrder &&
												itemObj.status === 4
											"
										>
											待审核
										</view>
										<view
											class="red_tag"
											v-if="
												!itemObj.reservation &&
												(store.state.isManager
													? itemObj.status == 4
													: itemObj.status == 2)
											"
										>
											未预约
										</view>
										<view
											class="red_tag"
											v-if="
												!itemObj.signIn &&
												(store.state.isManager
													? itemObj.status == 4
													: itemObj.status == 2)
											"
										>
											未签到
										</view>
									</view>
									<view class="list-item_contenVo">
										<view class="list-item_contenVo_left">
											<view class="list-item_contenVo_left_tip">
												联系方式：
											</view>
											<view class="list-item_contenVo_left_wNo">
												{{ setPhone(itemObj.userPhone) }}
											</view>
										</view>
									</view>
									<view class="list-item_contenVo">
										<view class="list-item_contenVo_left">
											<view class="list-item_contenVo_left_tip">
												客户地址：
											</view>
											<view class="list-item_contenVo_left_wNo">
												{{
													itemObj.province +
													itemObj.city +
													itemObj.area +
													itemObj.town +
													itemObj.address
												}}
											</view>
										</view>
									</view>
									<view class="list-item_contenVo">
										<view class="list-item_contenVo_left">
											<view class="list-item_contenVo_left_tip">
												报单时间：
											</view>
											<view class="list-item_contenVo_left_wNo">
												{{ itemObj.createTime }}
											</view>
										</view>
									</view>
									<view class="list-item_footer">
										<image
											class="list-item_footer_img"
											src="../../../static/network/order/time.svg"
											mode="aspectFit"
										></image>
										<view
											class="list-item_footer_time"
											v-if="store.state.isManager"
										>
											{{
												itemObj.status == 1 || itemObj.status == 2
													? '客服派单时间'
													: itemObj.status == 3
													? '派工时间'
													: itemObj.status == 4
													? '预约时间'
													: itemObj.status == 5
													? '申请时间'
													: itemObj.status == 6
													? '完成时间'
													: itemObj.status == 7
													? '取消时间'
													: '结单时间'
											}}:
											{{
												itemObj.status == 1 || itemObj.status == 2
													? itemObj.serviceDispatchTime
													: itemObj.status == 3
													? itemObj.networkDispatchTime
													: itemObj.status == 4
													? `${
															itemObj.reservationDate
																? itemObj.reservationDate +
																  ' ' +
																  itemObj.reservationStartTime +
																  '~' +
																  itemObj.reservationEndTime
																: ''
													  }`
													: itemObj.status == 5
													? itemObj.applyfinishTime
													: itemObj.status == 6
													? itemObj.endOrderTime
													: itemObj.status == 7
													? itemObj.cancelTime
													: itemObj.endorderTime
											}}
										</view>
										<view class="list-item_footer_time" v-else>
											{{
												itemObj.status == 1
													? '派工时间'
													: itemObj.status == 2
													? '预约时间'
													: itemObj.status == 3
													? '申请时间'
													: itemObj.status == 4
													? '完成时间'
													: itemObj.status == 5
													? '取消时间'
													: '结单时间'
											}}:
											{{
												itemObj.status == 1
													? itemObj.networkDispatchTime
													: itemObj.status == 2
													? `${
															itemObj.reservationDate
																? itemObj.reservationDate +
																  ' ' +
																  itemObj.reservationStartTime +
																  '~' +
																  itemObj.reservationEndTime
																: ''
													  }`
													: itemObj.status == 3
													? itemObj.applyfinishTime
													: itemObj.status == 4
													? itemObj.endOrderTime
													: itemObj.status == 5
													? itemObj.cancelTime
													: itemObj.endOrderTime
											}}
										</view>
									</view>
								</view>
								<view
									class="no_some"
									v-if="PageTotalData[currentTab].dataList.length > 0"
								>
									{{ title }}
								</view>
							</view>
							<view
								v-if="PageTotalData[currentTab].dataList.length == 0"
								class="void_goods"
							>
								<image class="img" src="/static/goods.svg"></image>
								<view class="tip">暂无工单</view>
							</view>
						</scroll-view>
					</view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script setup lang="ts">
	import {ref, onMounted, reactive, watch, nextTick, computed} from 'vue';
	import {onUnload, onShow, onLoad, onHide} from '@dcloudio/uni-app';
	import NavTabbar from '@/components/u-network/nav-tabbar.vue';
	import apiOrder from '@/util/network_api/apiOrder.js';
	import store from '@/store_network/index.js';
	import _ from 'lodash';

	const childStatusList = computed(() => {
		if (tabs.value[currentTab.value].status == 4) {
			return tabsChildStatus.value;
		}

		return tabsChildStatus6.value;
	});

	const navbarStatusHeight = ref(0);
	const navBarHeight = ref(0);
	const navBarWidth = ref(375);
	onMounted(() => {
		const info = uni.getSystemInfoSync();
		navbarStatusHeight.value = info.statusBarHeight;
		// 根据微信小程序的右上侧的胶囊样式 设置导航栏内容的高度
		// 条件编译 以下三个不支持胶囊样式
		// #ifndef H5 || APP-PLUS || MP-ALIPAY
		const menuInfo = uni.getMenuButtonBoundingClientRect();
		// 导航栏内容的高度 = (胶囊底部的高度 - 状态栏的高度) + (胶囊顶部的高度 - 状态栏的高度)
		navBarHeight.value =
			menuInfo.bottom -
			info.statusBarHeight +
			(menuInfo.top - info.statusBarHeight);
		// 导航栏内容的宽度  除开胶囊按钮左侧的内容宽度
		navBarWidth.value = menuInfo.left;
		// #endif
	});

	const copyText = (data) => {
		uni.setClipboardData({
			data: data,
			success() {
				uni.showToast({
					title: '已复制',
					icon: 'success',
				});
			},
		});
	};
	// 管理员
	const tabsList = ref([
		{status: null, name: '全部'},
		{status: 1, name: '待接单'},
		{status: 2, name: '待派工'},
		{status: 3, name: '待工程师接单'},
		{status: 4, name: '服务中'},
		{status: 5, name: '待结单'},
		{status: 8, name: '待核销'},
		{status: 2000, name: '已挂起'},
		{status: 6, name: '已完成'},
		{status: 7, name: '已取消'},
		// { status: 50, name: '待结算' }
	]);
	// 工程师
	const tabsList2 = ref([
		{status: null, name: '全部'},
		{status: 1, name: '待接单'},
		{status: 4, name: '服务中'},
		{status: 5, name: '待结单'},
		{status: 8, name: '待核销'},
		{status: 2000, name: '已挂起'},
		{status: 6, name: '已完成'},
		{status: 7, name: '已取消'},
		// { status: 50, name: '待结算' }
	]);
	// 服务中--子状态
	const tabsChildStatus4 = ref([
		{status: null, name: '全部'},
		{status: 1, name: '转单待审核'},
		{status: 2, name: '取消待审核'},
		{status: 3, name: '改派待审核'},
		{status: 4, name: '未拨打电话'},
		{status: 5, name: '未预约'},
		{status: 6, name: '未签到'},
		{status: 7, name: '费用待审核'},
		{status: 8, name: '配件待审核'},
	]);

	const tabsChildStatus = ref([]);
	// 已完成、已取消----子状态
	const tabsChildStatus6 = ref([
		{status: null, name: '全部'},
		{status: 1, name: '待结算'},
		{status: 3, name: '已结算'},
	]);

	//工程师状态
	const statusList2 = ref([
		{status: 1, name: '待接单', color: '#f56c6c'},
		{status: 2, name: '服务中', color: '#00c0c0'},
		{status: 3, name: '待结单', color: '#e69103'},
		{status: 4, name: '已完成', color: '#007cff'},
		{status: 2000, name: '已挂起', color: '#e69103'},
		{status: 5, name: '已取消', color: '#cccccc'},
		{status: 50, name: '待结算', color: '#e69103'},
	]);
	const statusList = ref([
		{status: 1, name: '待接单', color: '#f56c6c'},
		{name: '待派工', status: 2, color: '#e69103'},
		{name: '待工程师接单', status: 3, color: '#e69103'},
		{name: '服务中', status: 4, color: '#00c0c0'},
		{name: '待结单', status: 5, color: '#e69103'},
		{name: '已完成', status: 6, color: '#007cff'},
		{status: 2000, name: '已挂起', color: '#e69103'},
		{name: '已取消', status: 7, color: '#ccc'},
		{name: '待结算', status: 50, color: '#e69103'},
	]);
	const tabs = ref([]); //标题列表
	const status = ref([]);
	const currentTab = ref(0); //当前标题index
	const tabCurrent = ref('tabNum0');
	const currentTabChild = ref(0); //子状态  当前标题index
	const tabCurrentChild = ref('tabNumChild0');

	// Tab切换内容
	async function swichMenu(index) {
		if (index == currentTab.value) return;
		currentTab.value = index;
		tabCurrent.value = 'tabNum' + index;
		PageTotalData.value[currentTab.value].page = 1;
		selectVo.value.page = 1;
		currentTabChild.value = 0;
		tabCurrentChild.value = 'tabNumChild0';
		uni.showLoading({
			title: '加载中',
		});
		Promise.all([getNetworkList(), getNetworkOrderListStatusQtyObj()]).then(
			() => {
				uni.hideLoading();
			},
		);
	}
	// Tab 子状态 切换内容
	async function swichMenuChild(index: number) {
		if (index == currentTabChild.value) return;
		currentTabChild.value = index;
		tabCurrentChild.value = 'tabNumChild' + index;
		PageTotalData.value[currentTab.value].page = 1;
		selectVo.value.page = 1;
		uni.showLoading({
			title: '加载中',
		});
		Promise.all([getNetworkList(), getNetworkOrderListStatusQtyObj()]).then(
			() => {
				uni.hideLoading();
			},
		);
	}
	// 状态数据
	const PageTotalData = ref([]);
	const selectVo = ref({
		keyword: '', //搜索关键词：工单单号/一物一码/产品名称/产品型号
		limit: 0,
		page: 1,
		status: null, //1-待接单，2-待派工，3-待工程师确认接单，4-服务中，5-待结单，6-已完成/已取消，50-待结算--管理员2,3才显示
		childStatus: null,
		isPause: 0,
	});

	// 根据管理员 判断显示
	const changeSuperManager = async (
		statusParent = null,
		childStatus = null,
	) => {
		PageTotalData.value = [];
		if (!store.state.isManager) {
			tabs.value = tabsList2.value;
			status.value = statusList2.value;
			tabsChildStatus.value = tabsChildStatus4.value.filter(
				(o) => !(o.status == 2 || o.status == 3),
			);
		} else {
			tabs.value = tabsList.value;
			status.value = statusList.value;
			tabsChildStatus.value = tabsChildStatus4.value;
		}

		tabs.value.map((o) => {
			PageTotalData.value.push({page: 1, total: 0, dataList: []});
			return o;
		});

		nextTick(() => {
			if (!statusParent || statusParent == 'null') {
				currentTab.value = 0;
				tabCurrent.value = 'tabNum0';
			} else {
				currentTab.value = tabs.value.findIndex(
					(o) => o.status == statusParent,
				);
				tabCurrent.value = 'tabNum' + currentTab.value;
			}

			if (statusParent == 4 || statusParent == 6 || statusParent == 7) {
				if (childStatus == 'null' || !childStatus) {
					currentTabChild.value = 0;
					tabCurrentChild.value = 'tabNumChild0';
				} else {
					currentTabChild.value = tabsChildStatus.value.findIndex(
						(o) => o.status == childStatus,
					);
					tabCurrentChild.value = 'tabNumChild' + currentTabChild.value;
				}
			}

			Promise.all([getNetworkList(), getNetworkOrderListStatusQtyObj()]).then(
				() => {
					uni.hideLoading();
				},
			);
		});
	};

	// 处理隐藏手机号
	function setPhone(str) {
		let tem = str.slice(0, 3) + '****' + str.slice(str.length - 4);
		return tem;
	}
	onShow(async () => {
		// uni.showLoading({
		// 	title: '加载中',
		// })
		// await store.dispatch('getUpdataUser')
		// changeSuperManager()
	});
	// *************end********
	// 获取工单列表
	const getNetworkList = async () => {
		selectVo.value.status = tabs.value[currentTab.value].status;
		if (selectVo.value.status === 2000) {
			selectVo.value.status = null;
			selectVo.value.isPause = 1;
		} else {
			selectVo.value.isPause = 0;
		}
		if (selectVo.value.status == 4) {
			selectVo.value.childStatus =
				tabsChildStatus.value[currentTabChild.value].status;
		} else if (selectVo.value.status == 6 || selectVo.value.status == 7) {
			selectVo.value.childStatus =
				tabsChildStatus6.value[currentTabChild.value].status;
		} else if (selectVo.value.status == 8) {
			selectVo.value.childStatus = 9
		} else {
			selectVo.value.childStatus = null;
		}
		await apiOrder.getNetworkOrderList(selectVo.value).then((res) => {
			if (res.code == 20000) {
				if (triggered.value) {
					PageTotalData.value[currentTab.value].dataList = [];
				}
				if (PageTotalData.value[currentTab.value].page > 1) {
					PageTotalData.value[currentTab.value].dataList = [
						...PageTotalData.value[currentTab.value].dataList,
						...res.data.rows,
					];
				} else {
					PageTotalData.value[currentTab.value].dataList = res.data.rows;
				}
				PageTotalData.value[currentTab.value].total = res.data.total - 0;
			}
		});
	};
	// 获取状态
	const OrderStatusQty = ref(null); //状态数量
	const getNetworkOrderListStatusQtyObj = () => {
		apiOrder
			.getNetworkOrderListStatusQty({keyword: selectVo.value.keyword})
			.then((res) => {
				if (res.code == 20000) {
					OrderStatusQty.value = res.data.row;
				}
			});
	};
	// 底部显示提示
	const title = ref('没有更多工单了');
	// 滚动到底部触发
	const scrolltolower = async () => {
		if (
			PageTotalData.value[currentTab.value].total >
			PageTotalData.value[currentTab.value].dataList.length
		) {
			PageTotalData.value[currentTab.value].page =
				PageTotalData.value[currentTab.value].page + 1;
			selectVo.value.page = PageTotalData.value[currentTab.value].page;
			title.value = '';
			uni.showLoading({
				title: '加载中...',
			});
			Promise.all([getNetworkList(), getNetworkOrderListStatusQtyObj()]).then(
				() => {
					uni.hideLoading();
				},
			);
		} else {
			title.value = '没有更多工单了';
		}
	};

	// 下拉刷新触发
	const triggered = ref(false);
	const refresherpulling = (e) => {
		if (e.detail.deltaY < 0) return; // 防止上滑页面也触发下拉
		triggered.value = true;
	};
	const onRefresh = () => {
		PageTotalData.value[currentTab.value].page = 1;
		selectVo.value.keyword = '';
		selectValue.value = '';
		selectVo.value.page = 1;
		Promise.all([getNetworkList(), getNetworkOrderListStatusQtyObj()]).then(
			() => {
				setTimeout(() => {
					triggered.value = false;
				}, 500);
			},
		);
	};
	// 搜索
	const selectValue = ref('');
	const clear = () => {
		selectValue.value = '';
		search();
	};
	const search = _.debounce(async () => {
		selectVo.value.keyword = selectValue.value.trim();
		currentTab.value = 0;
		selectVo.value.page = 1;
		PageTotalData.value[currentTab.value].page = 1;
		uni.showLoading({
			title: '加载中...',
		});
		Promise.all([getNetworkList(), getNetworkOrderListStatusQtyObj()]).then(
			() => {
				uni.hideLoading();
			},
		);
	}, 500);
	const input = (n) => {
		if (!n) {
			search();
		}
	};

	// 设置对应的工单状态数量 超过99+
	const setOrderNum = (index: any, parentIndex = null) => {
		if (parentIndex) {
			if (parentIndex == 4) {
				switch (index) {
					case null:
						var num: any = 0;
						if (OrderStatusQty.value.serviceStatusQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.serviceStatusQty;
						}
						return num;
					case 1:
						var num: any = 0;
						if (OrderStatusQty.value.transferOrderWaitCheckQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.transferOrderWaitCheckQty;
						}
						return num;
					case 2:
						var num: any = 0;
						if (OrderStatusQty.value.cancelOrderWaitCheckQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.cancelOrderWaitCheckQty;
						}
						return num;
					case 3:
						var num: any = 0;
						if (OrderStatusQty.value.changeOrderWaitCheckQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.changeOrderWaitCheckQty;
						}
						return num;
					case 4:
						var num: any = 0;
						if (OrderStatusQty.value.waitCallPhoneQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.waitCallPhoneQty;
						}
						return num;
					case 5:
						var num: any = 0;
						if (OrderStatusQty.value.waitReservationQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.waitReservationQty;
						}
						return num;
					case 6:
						var num: any = 0;
						if (OrderStatusQty.value.waitSignQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.waitSignQty;
						}
						return num;
					case 7:
						var num: any = 0;
						if (OrderStatusQty.value.feeWaitCheckQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.feeWaitCheckQty;
						}
						return num;
					case 8:
						var num: any = 0;
						if (OrderStatusQty.value.spareWaitCheckQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.spareWaitCheckQty;
						}
						return num;
				}
			} else if (parentIndex == 6) {
				switch (index) {
					case null:
						var num: any = 0;
						if (OrderStatusQty.value.finishTotalOrderSettlementQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.finishTotalOrderSettlementQty;
						}
						return num;
					case 1:
						var num: any = 0;
						if (OrderStatusQty.value.finishOrderWaitSettlementQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.finishOrderWaitSettlementQty;
						}
						return num;
					case 2:
						var num: any = 0;
						if (OrderStatusQty.value.finishOrderSettlementQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.finishOrderSettlementQty;
						}
						return num;
				}
			} else if (parentIndex == 8) {
				switch (index) {
					case null:
						var num: any = 0;
						if (OrderStatusQty.value.hxWaitQty > 100) {
							num = '99+';
						} else {
							num = OrderStatusQty.value.hxWaitQty;
						}
						return num;
				}
			}
		} else if (parentIndex == 7) {
			switch (index) {
				case null:
					var num: any = 0;
					if (OrderStatusQty.value.cancelOrderQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.cancelOrderQty;
					}
					return num;
				case 1:
					var num: any = 0;
					if (OrderStatusQty.value.cancelOrderWaitSettlementQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.cancelOrderWaitSettlementQty;
					}
					return num;
				case 2:
					var num: any = 0;
					if (OrderStatusQty.value.cancelOrderSettlementQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.cancelOrderSettlementQty;
					}
					return num;
			}
		} else {
			switch (index) {
				case null:
					var num: any = 0;
					if (OrderStatusQty.value.total > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.total;
					}
					return num;
				case 1:
					var num: any = 0;
					if (OrderStatusQty.value.waitReceivingOrderStatusQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.waitReceivingOrderStatusQty;
					}
					return num;
				case 2:
					var num: any = 0;
					if (OrderStatusQty.value.waitDispatchStatusQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.waitDispatchStatusQty;
					}
					return num;
				case 3:
					var num: any = 0;
					if (OrderStatusQty.value.waitEngineerReceivingOrderStatusQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.waitEngineerReceivingOrderStatusQty;
					}
					return num;
				case 4:
					var num: any = 0;
					if (OrderStatusQty.value.serviceStatusQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.serviceStatusQty;
					}
					return num;
				case 5:
					var num: any = 0;
					if (OrderStatusQty.value.waitStatementOrderStatusQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.waitStatementOrderStatusQty;
					}
					return num;
				case 6:
					var num: any = 0;
					if (OrderStatusQty.value.finishTotalOrderSettlementQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.finishTotalOrderSettlementQty;
					}
					return num;
				case 7:
					var num: any = 0;
					if (OrderStatusQty.value.cancelOrderQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.cancelOrderQty;
					}
					return num;
				case 8:
					var num: any = 0;
					if (OrderStatusQty.value.hxWaitQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.hxWaitQty;
					}
					return num;
				case 50:
					var num: any = 0;
					if (OrderStatusQty.value.waitSettlementOrderStatusQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.waitSettlementOrderStatusQty;
					}
					return num;
				case 2000:
					var num: any = 0;
					if (OrderStatusQty.value.isPauseQty > 100) {
						num = '99+';
					} else {
						num = OrderStatusQty.value.isPauseQty;
					}
					return num;
			}
		}
	};

	const goDetail = (id: string) => {
		uni.navigateTo({
			url: `/pages/pages_network/order/detail?workId=${id}`,
		});
	};

	onLoad(async (e) => {
		uni.showLoading({
			title: '加载中',
		});

		// 获取用户信息
		await store.dispatch('getUpdataUser');

		if (e.statusParent || e.childStatus) {
			changeSuperManager(e.statusParent, e.childStatus);
		} else {
			changeSuperManager();
		}
	});

	onUnload(() => {
		uni.hideLoading();
	});
</script>

<style lang="scss" scoped>
	.order_main {
		/* #ifdef H5 */
		height: calc(100vh - 44px);
		/* #endif */
		/* #ifndef H5 */
		height: 100vh;
		/* #endif */
		width: 100vw;
		background-image: url('../../../static/network/bg_main.png');
		background-position: top;
		background-repeat: no-repeat;
		background-size: cover;
		display: flex;
		flex-direction: column;
		overflow: hidden;

		.fixed {
			// position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			width: 100%;
		}

		.navbar-content {
			position: relative;
			display: flex;
			align-items: center;
			width: 100%;
			height: 80rpx;

			.back_btn {
				margin-left: 12rpx;
				position: relative;
				z-index: 9;
			}

			.navBar {
				display: flex;
				flex-direction: row;
				justify-content: center;
				align-items: center;
				position: absolute;
				top: 0;
				bottom: 0;
				width: 100%;
				height: 100%;
				font-size: 32rpx;
				font-weight: bold;
				color: #fff;
			}
		}

		:deep(.uni-searchbar__cancel) {
			color: #ffffff;
		}

		.body-view {
			display: flex;
			flex: 1;
			flex-direction: column;
			position: relative;

			:deep(.uni-scroll-view) {
				-ms-overflow-style: none;
				/* IE and Edge */
				scrollbar-width: none;

				/* Firefox */
				&::-webkit-scrollbar {
					width: 0;
					height: 0;
					background-color: transparent;
				}
			}

			.search_box {
				display: flex;
				align-items: center;
				// width: 100%;
				padding: 24rpx;
				background-color: #fff;

				:deep(.uni-easyinput__content) {
					background-color: #f3f4f8 !important;
					border-radius: 50rpx;
				}

				.search {
					flex: 1;
					padding: 0 12rpx;
				}

				.search_btn {
					font-size: 28rpx;
					font-weight: bold;
					// color: #fff;
					color: #007cff;
					margin-left: 12rpx;
					// background-image:-webkit-linear-gradient(top,#fff, #007cff);
					// -webkit-background-clip:text;
					// -webkit-text-fill-color:transparent;
				}
			}

			.search_right {
				position: absolute;
				right: 0;
				top: 0;
				z-index: 9999;
				background: linear-gradient(to right, #ffffff2b 0%, #fff 30%);
				width: 90rpx;
				height: 86rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				padding-left: 20rpx;
			}

			.top-menu-view {
				display: flex;
				// position: fixed;
				// top: 100rpx;
				// left: 0;
				white-space: nowrap;
				width: 100%;
				background-color: #ffffff;
				height: 86rpx;
				line-height: 86rpx;
				// border-top: 1rpx solid #d8dbe6;
				border-bottom: 1rpx solid #d8dbe6;

				&.top-menu-view-child {
					height: 66rpx;
					line-height: 66rpx;
				}

				.menu-topic-view {
					display: inline-block;
					white-space: nowrap;
					height: 100%;
					position: relative;
					padding: 0rpx 10rpx;

					.menu-topic-text {
						font-size: 28rpx;
						color: #303133;
						margin: 0 30rpx;
						position: relative;
						z-index: 2;
						border-radius: 10rpx;
						font-weight: 700;
					}

					.red_num {
						border-radius: 50%;
						min-width: 44rpx;
						height: 44rpx;
						position: absolute;
						top: 4rpx;
						right: -4rpx;
						color: #fff;
						background-color: #ff5733;
						font-size: 20rpx;
						z-index: 1;
						padding: 2rpx;
						box-sizing: border-box;
						display: flex;
						align-items: center;
						justify-content: center;
						box-sizing: border-box;
					}

					.num_child {
						border-radius: 50%;
						width: 36rpx;
						height: 36rpx;
						position: absolute;
						top: 6rpx;
						right: 0rpx;
						color: #ff5733;
						font-size: 22rpx;
						z-index: 1;
						display: flex;
						align-items: center;
						justify-content: center;
					}

					.menu-topic-bottom {
						position: absolute;
						bottom: 4rpx;
						left: 0;
						right: 0;
						margin: 0 40rpx;

						.menu-topic-bottom-color {
							width: 100%;
							height: 4rpx;
						}
					}

					.menu-topic-act {
						display: flex;
						flex-direction: column;

						.menu-topic-text {
							font-weight: 700;
							color: #007cff;
						}

						.menu-topic-bottom {
							display: flex;
							justify-content: center;
						}

						.menu-topic-bottom-color {
							background: #007cff;
						}
					}
				}
			}

			.swiper-box-list {
				width: 100%;
				flex: 1;

				.swiper-topic-list {
					width: 100%;

					.scroll_content {
						height: 100%;
						// padding: 0 24rpx 24rpx;
						box-sizing: border-box;

						.scroll-view_list {
							height: 100%;

							.void_goods {
								display: flex;
								justify-content: center;
								align-items: center;
								flex-direction: column;
								width: 100%;
								height: 40vh;

								.img {
									width: 60%;
									height: 250rpx;
								}

								.tip {
									color: #aaa;
									font-size: 28rpx;
								}
							}

							.pag_bottom {
								padding-bottom: 300rpx;
							}

							.list-item {
								background-color: #ffffff;
								margin: 30rpx 24rpx;
								padding: 12rpx 0 24rpx 24rpx;
								font-size: 28rpx;
								border-radius: 10rpx;

								&_contenVo {
									display: flex;
									flex-wrap: nowrap;
									align-items: center;
									padding: 8rpx 0;

									.red_tag {
										font-size: 24rpx;
										margin: 0 12rpx;
										color: rgba(245, 108, 108, 1);
									}

									&_left {
										display: flex;
										align-items: center;
										flex-wrap: nowrap;
										flex: 1;

										&_wNo,
										&_tip {
											white-space: nowrap;
										}

										&_tip {
											color: #777;
										}

										&_wNo {
											margin-right: 10rpx;
											text-overflow: ellipsis;
											overflow: hidden;
											white-space: nowrap;
										}

										&_mo {
											flex: 1;
											text-overflow: ellipsis;
											overflow: hidden;
											white-space: nowrap;
											color: #00c0c0;
											font-size: 24rpx;
										}

										// text-overflow: ellipsis;
										overflow: hidden;
										// white-space: nowrap;
									}

									&_right {
										display: flex;
										flex-wrap: nowrap;
										flex: 1;

										&_tag {
											font-size: 22rpx;
											border-radius: 25rpx 0 0 25rpx;
											color: #ffffff;
											padding: 8rpx 16rpx;
											position: relative;
											right: -5rpx;

											&::after {
												content: '';
												position: absolute;
												right: -5rpx;
												bottom: -5rpx;
												border: 5rpx solid transparent;
												border-left-width: 5rpx;
												border-left-color: var(--item-color);
											}
										}
									}
								}

								&_footer {
									display: flex;
									align-items: center;
									color: rgba(85, 85, 85, 1);
									padding: 8rpx;
									margin-right: 24rpx;
									margin-top: 12rpx;
									border-radius: 8rpx;
									background-color: rgba(246, 247, 248, 1);

									&_img {
										width: 30rpx;
										height: 30rpx;
									}

									&_time {
										margin: 0 8rpx;
									}
								}
							}

							.no_some {
								font-size: 24rpx;
								color: #ccc;
								text-align: center;
								width: 100%;
								padding-bottom: 24rpx;
							}
						}
					}
				}
			}
		}
	}
</style>
